#include "interior_point.h"

void interior_point_method(NLPProblem *problem, double *x0, double mu0, double tol, int max_iter) 
{
    double mu = mu0;
    double *x = (double *)malloc(problem->n * sizeof(double));
    memcpy(x, x0, problem->n * sizeof(double));
    
    for (int k = 0; k < max_iter; k++) {
        // 使用牛顿法求解当前障碍问题
        newton_method(problem, x, mu, tol/10);
        
        // 更新障碍参数
        mu *= 0.1;
        
        // 检查收敛条件
        if (mu < tol) break;
    }
    
    free(x);
}